package com.mxnavi5.example.DataStream;

import org.apache.flink.streaming.api.functions.source.RichParallelSourceFunction;

import java.util.Random;

public class UdfSourceTest3 extends RichParallelSourceFunction {

    boolean running = true;
    Random random = new Random();

    @Override
    public void run(SourceContext sourceContext) throws Exception {
        Integer[] integers = new Integer[]{1000, 1000, 2000, 3000, 11000, 4000, 13000, 5000, 19000, 9000,22000};
        while (running){
            for (int i = 0; i < integers.length; i++) {
                Thread.sleep(300);
                sourceContext.collect(integers[i]);
                Thread.sleep(300);
            }
            Thread.sleep(10000000);
        }
    }

    @Override
    public void cancel() {
        running = false;
    }
}
